<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
	<style type="text/css">
	   .gray-bg
	   {
	     background-color: #fff;
	   }
	</style>
</head>
<body class="gray-bg">
	 <div class="ibox-content">
		<form class="form-horizontal m-t" id="commentForm">
			<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="90%" class="tablefont">
				<tr>
				    <td width="23%" align="right">
				    	<label class="col-sm-3 control-label rp">所属公司：</label>
				    </td>
					<td width="75%">
						<div class="form-group">
		    				<select id="companyCode" name="companyCode" class="select-control"></select>
	    				</div>
					</td>
				</tr>
				
				<tr>
				    <td width="23%" align="right">
				    	<label class="col-sm-3 control-label np">父级名称：</label>
				    </td>
					<td width="75%">
						<div class="form-group">
	    					<input id="parentId" name="parentId" style="display:none">
	    					<input id="parentValue" name="parentValue"  type="text" class="form-control smalliconcur smallicon"  readonly="readonly"  aria-required="true" >
	    				</div>
					</td>
				</tr>
				
				<tr>
				    <td width="25%" align="right">
				    	<label class="col-sm-3 control-label np">菜单名称：</label>
				    </td>
					<td width="75%">
						<div class="form-group">
	    					<input id="menuName" name="menuName"  type="text" class="form-control" aria-required="true" required="required"   minlength="1" maxlength="64" placeholder="请输入菜单名称(必填)" />
	    				</div>
					</td>
				</tr>
				
				<tr>
				    <td width="23%" align="right">
				    	<label class="col-sm-3 control-label rp">菜单代码：</label>
				    </td>
					<td width="75%">
						<div class="form-group">
	    					<input id="menuCode" name="menuCode"  type="text" class="form-control" aria-required="true" required="required"  minlength="1" maxlength="64" placeholder="请输入菜单代码(必填)">
	    				</div>
					</td>
				</tr>
				
				<tr>
					<td width="23%" align="right">
						<div class="col-sm-3">
							<label class="control-label np">菜单排序：</label>
						</div>
					</td>
					<td  width="75%">
						<div class="form-group">		
	    					<input id="sortValue" name="sortValue" minlength="1" min="1" maxlength="11" type="number" class="form-control" required="required" placeholder="菜单排序(必填)" >
		    			</div>	
					</td>
				</tr>
				
				<tr>
				    <td width="23%" align="right">
				    	<label class="col-sm-3 control-label rp">备注：</label>
				    </td>
					<td width="75%">
						<div class="form-group">
	    					<textarea id="remarks" name="remarks" cols="20" rows="3" type="text" class="form-control" aria-required="true" placeholder="请输入备注" ></textarea>
	    				</div>
					</td>
				</tr>

			</table>
			<table cellpadding="0" cellspacing="0" border="0" bordercolor="#3B95C8"  width="100%">
				<tr>
					<td width="100%" align="center">
						 <div class="ibox-content">
				              <button type="button" class="btn dpbtn_green" onclick="appMenuSave();">确定</button>
				              <button type="button" class="btn dpbtn_red" onclick="Reset();">重置</button>
				          </div>
					</td>
				</tr>
			</table>
		</form>
	</div>
	
	
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>

 	<!-- custom js -->
    
    <script type="text/javascript" src="${basePath}/js/commonvalidate.js" charset="utf-8"></script>
    
    
    <!--
    	作者：zhangpp
    	时间：2017-04-06
    	描述：js
    -->
    <script type="text/javascript">
	    $(function(){
	    	$("#parentId").val($.getUrlData("parentId"));
	    	var parentName = $.getUrlData("parentName");
	    	$("#parentValue").val(parentName);
	    	companyCode();
	    });
	    
	    function companyCode(){
	    	  $.dpAjax({
	    	    	url:'${basePath}/DataDictionaryController/getEnableList',
	     			data:{"parentValue":"Company"},
	     			success: function(datas){
	     			  var result = datas.result.rows;
	  				  var html="";
	  			      for(var i=0;i<result.length;i++){
	  			          var programme = result[i];
	  			          html += '<option value="'+programme.value+'">'+programme.name+'</option>';
	  			      }
	  			      $("#companyCode").html(html);
	               }
	    	   });
	      } 
	    
		var appMenuSave = function()
		{
			var validstatus = $("#commentForm").valid();
	    	if(validstatus)
	    	{
	    		var data = $('#commentForm').serialize();
    			layer.confirm('您确认要增加吗？', {
   		  			  btn: ['确定','取消'] //按钮
   				},function(){
   					layer.closeAll();
   					$.dpAjax({
   						url:'${basePath}/appMenu/add',
   						data:data,
   		     			success: function(datas){
   		     				  layer.msg("添加执行成功！", {icon: 6});
   	     				 	  parent.layer.close(parent.addlayer);
   	 						  return;
   		                 }
   		 	    	});
   					   					
   				});
	    		
	    	}
		}
		
		var Reset = function(){
			document.getElementById('companyCode').value = "dp";
			document.getElementById('menuName').value = "";
			document.getElementById('menuCode').value = "";
			document.getElementById('sortValue').value = "";
			document.getElementById('remarks').value = "";
		}
  		
		
		 $(function(){
			 $("#commentForm").validate({
			    rules: {
		            sortValue: {
		            	zhengZS: true,
		            },
		        },
		        //重写showErrors
		        showErrors: function (errorMap, errorList) {
		            
		            $.each(errorList, function (i, v) {
		                layer.tips(v.message, v.element, { time: 1500 });
		                return false;
		            });  
		        },
		        /* 失去焦点时验证 */
		        onfocusout: function(element) { $(element).valid(); },
		        /*  键盘抬起不验证 */
		        onkeyup:false,
			 });
	 	})
    </script>
</body>
</html>
